import Vue from "vue"
import Router from "vue-router"

Vue.use(Router)
//添加以下代码
const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
const router = new Router({
  mode: "history",
  routes: [
    {
      path: "/",
      name: "login",
      component: resolve => require(["@/components/Login"], resolve),
      meta: {
        showNav: true
      }
    },
    {
      path: "/index",
      name: "index",
      component: resolve => require(["@/components/index"], resolve),
      meta: {
        title: "首页"
      }
    },
    {
      path: "/agent",
      name: "agent",
      component: resolve => require(["@/components/agentGroup/agent/index"], resolve),
      meta: {
        title: "代理商列表"
      }
    },
    {
      path: "/addlist",
      name: "addlist",
      component: resolve => require(["@/components/agentGroup/agent/addlist"], resolve),
      meta: {
        title: "添加代理商"
      }
    },
    {
      path: "/agentsee",
      name: "agentsee",
      component: resolve => require(["@/components/agentGroup/agent/agentsee"], resolve),
      meta: {
        title: "代理商详情"
      }
    },
    {
      path: "/SecondaryList",
      name: "SecondaryList",
      component: resolve =>
        require(["@/components/agentGroup/agent/SecondaryList"], resolve),
      meta: {
        title: "子代理商列表"
      }
    },
    {
      path: "/PlatformCost",
      name: "PlatformCost",
      component: resolve =>
        require(["@/components/agentGroup/agent/PlatformCost"], resolve),
      meta: {
        title: "平台成本"
      }
    },
    {
      path: "/organizationList",
      name: "organizationList",
      component: resolve =>
        require(["@/components/systemGroup/organization/list"], resolve),
      meta: {
        title: "组织管理"
      }
    },
    {
      path: "/organizationDetail",
      name: "organizationDetail",
      component: resolve =>
        require(["@/components/systemGroup/organization/detail"], resolve),
      meta: {
        title: "员工详情"
      }
    },
    {
      path: "/organizationAdd",
      name: "organizationAdd",
      component: resolve => require(["@/components/systemGroup/organization/add"], resolve),
      meta: {
        title: "添加部门"
      }
    },
    {
      path: "/menuList",
      name: "menuList",
      component: resolve =>
        require(["@/components/systemGroup/menuPage/menuList"], resolve),
      meta: {
        title: "菜单权限"
      }
    },
    {
      path: "/organization",
      name: "organization",
      component: resolve =>
        require(["@/components/systemGroup/menuPage/organization"], resolve),
      meta: {
        title: "组织架构"
      }
    },
    {
      path: "/addorgan",
      name: "addorgan",
      component: resolve =>
        require(["@/components/systemGroup/menuPage/addorgan"], resolve),
      meta: {
        title: "新增组织"
      }
    },
    {
      path: "/PlatformStaff",
      name: "PlatformStaff",
      component: resolve =>
        require(["@/components/systemGroup/menuPage/PlatformStaff"], resolve),
      meta: {
        title: "平台员工"
      }
    },
    {
      path: "/PsAdd",
      name: "PsAdd",
      component: resolve => require(["@/components/systemGroup/menuPage/PsAdd"], resolve),
      meta: {
        title: "新增员工"
      }
    },
    {
      path: "/StoreList",
      name: "StoreList",
      component: resolve =>
        require(["@/components/storeGroup/list"], resolve),
      meta: {
        title: "门店列表"
      }
    },
    {
      path: "/StoreDetail",
      name: "StoreDetail",
      component: resolve =>
        require(["@/components/storeGroup/detail"], resolve),
      meta: {
        title: "添加成员"
      }
    },
    {
      path: "/jobButies",
      name: "jobButies",
      component: resolve =>
        require(["@/components/storeGroup/jobButies"], resolve),
      meta: {
        title: "职务管理"
      },
      props: true
    },
    {
      path: "/jobdetails",
      name: "jobdetails",
      component: resolve =>
        require(["@/components/storeGroup/jobdetails"], resolve),
      meta: {
        title: "成员详情"
      },
      props: true
    },
    {
      path: "/shiftRecords",
      name: "shiftRecords",
      component: resolve =>
        require(["@/components/storeGroup/shiftRecords"], resolve),
      meta: {
        title: "交班记录"
      },
      props: true
    },
    {
      path: "/merchant",
      name: "merchant",
      component: resolve =>
        require(["@/components/merchantGroup/index"], resolve),
      meta: {
        title: "全部商户"
      },
      props: true
    },
    {
      path: "/qrcode",
      name: "qrcode",
      component: resolve =>
        require(["@/components/merchantGroup/qrcode"], resolve),
      meta: {
        title: "聚合码"
      },
      props: true
    },
    {
      path: "/Merchantmeal",
      name: "Merchantmeal",
      component: resolve =>
        require(["@/components/merchantGroup/Merchantmeal/index"], resolve),
      meta: {
        title: "商家套餐"
      },
      props: true
    },
    {
      path: "/noeinList",
      name: "noeinList",
      component: resolve =>
        require(["@/components/merchantGroup/noein/list"], resolve),
      meta: {
        title: "进件管理"
      },
      props: true
    },
    {
      path: "/merchantadd",
      name: "merchantadd",
      component: resolve =>
        require(["@/components/merchantGroup/add"], resolve),
      meta: {
        title: "添加商户"
      },
      props: true
    }
  ]
})
router.beforeEach((to, from, next) => {
  if (to.params.parameter) {
    to.meta.title = to.params.parameter
  }
  next()
})
export default router
